feat(api-keys): add daily-spending-limit input and column - #432
Open
madroidmaq wants to merge 1 commit into
Open
feat(api-keys): add daily-spending-limit input and column#432madroidmaq wants to merge 1 commit into
madroidmaq wants to merge 1 commit into
Conversation
Add per-key daily-spending-limit (and the long-missing spending-limit) input fields to the API key edit dialog, a dedicated table column, and i18n entries (zh-CN/en). Mirrors CliRelay backend PR kittors#471 (per-day cost cap that resets daily). Cost-limit inputs render in Unrestricted/Custom permission modes and are submitted via float parsing. PermissionProfile application zeroes them, consistent with spending-limit (per backend EffectiveAPIKeyRowWithProfiles). Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
为 API Key 编辑对话框新增 per-key 费用限额输入框:
daily-spending-limit(每日消费上限)以及补上一直缺失的spending-limit(累计上限),配合 CliRelay 后端 PR kittors/CliRelay#471(Closes kittors/CliRelay#442)。Changes
ApiKeyFormFields:权限为「无限制 / 自定义」时显示spending-limit与daily-spending-limit两个 float(美元)输入框(step=0.01,placeholder0 = 无限制)。ApiKeysPage:编辑提交时在「无限制 / 自定义」模式从表单 float 解析这两个限额(不再透传原值)。applyApiKeyPermissionProfile:两个分支都把daily-spending-limit置 0(与spending-limit一致 —— 费用限额是 per-key,PermissionProfile 不承载)。ApiKeyColumns:新增dailySpendingLimit列(复用formatApiKeySpendingLimit美元格式化)。zh-CN/en新增col_daily_spending_limit、daily_spending_limit_help、form_spending_limit、form_daily_spending_limit(ru沿用 fallback —— 该语言无api_keys_page块)。设计说明
费用限额是 per-key 字段。后端
EffectiveAPIKeyRowWithProfiles在 key 绑定 PermissionProfile 时会把费用限额置零,因此输入框只在未绑定 profile 的权限模式(「无限制」/「自定义」)下显示并生效。在「无限制」模式下提交时,会清零其它限制但保留表单填写的费用限额(即「无 profile + 费用限额」)。
Verification
tsc --noEmit✓vitest(api-keys,20 tests)✓oxlint(0 errors)✓vite build✓Related
🤖 Generated with Claude Code